Repository navigation
fix(pm-dispatch): validate GitHub API response shapes at the boundary (#7101) - #8088
Conversation
…#7101) Installation id, access-token, issue-create and issue-lookup bodies in pm-stack/dispatch/src/github.ts were shape-trusted via bare casts: a wrong-shape 2xx minted against /installations/undefined, sent Bearer <redacted>, returned a phantom issue as success, fabricated a lookup state, and null bodies escaped as raw TypeErrors (the create one then duplicated the issue via the gh fallback). All four bodies are now validated before use; violations raise GitHubError naming the endpoint and the malformed field. A malformed 2xx create body no longer falls back to a gh create (the issue may already exist server-side); malformed installation/token replies still fall back with the reason preserved. New test/github.test.ts (stubbed fetch, nonexistent repo slug so the gh fallback fails deterministically): 12/12 pass post-fix, 9 fail pre-fix; full dispatch suite 169/169.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
🤖 Agent note · codex-gate disposition
|
Closes #7101. Queue task 12768 (lane code-w).
Problem
pm-stack/dispatch/src/github.tsshape-trusted every GitHub API response body via bare casts: installation{}minted against/app/installations/undefined/access_tokens, token{}was sent asBearer undefined, create{}returned a phantom{number: undefined, url: undefined}as success, lookup{}fabricated an issue state (rejected by #3007 attach verification as "is undefined, not open"), and null bodies escaped as raw TypeErrors — the create one then duplicated the tracking issue via the gh fallback.Fix
res.json()bodies (installation lookup, access-token mint, issue create, issue lookup — app route and the gh-route parse ingetIssue) are validated before use: JSON object body; installationida positive integer;tokena non-empty string with a parseableexpires_at; create/lookupnumberan integer,state/html_urlstrings.GitHubError(newMalformedBodyErrorsubclass) naming the endpoint and the malformed field — never a raw TypeError/SyntaxError, never a coerced/undefined value.Tests (oracle: the #7101 acceptance)
New
pm-stack/dispatch/test/github.test.ts, stubbed fetch in theattach_verify.test.tsstyle; the repo slug is a nonexistent one so the gh fallback fails deterministically and can never create a real issue in any environment.bunx tsc --noEmitin the bare worktree fails identically on the unpatched tree (missingbuntype definitions; no node_modules in the worktree) — pre-existing environment gap, not this change.Incident note: an early test draft's fake-gh PATH shim was not honored by
Bun.spawn, so the real gh fallback created ten fixture issues (#8075–#8084, title "t"); all ten were closed as not planned with an explanation in the same shift, and the test was redesigned (nonexistent slug) so this cannot recur.